<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

	<ui:composition template="/template.xhtml">
		<ui:define name="content">
			
			<p:layoutUnit position="north" size="200">
				<p:layout>
					<div align="center">
					
						<!-- LOGO -->
						<p:layoutUnit id="layoutLogo" position="west" size="190"> 
			            	<p:graphicImage value="/images/logo.jpg"/>
			            </p:layoutUnit>
               
						<!-- CABECALHO -->
		               	<p:layoutUnit id="layoutCabecalho" position="center">
		                   <h:form id="formCabecalho" >
			                   	<p:panelGrid>
									<p:row>
										<p:column>
											<h:outputText id="textCabecalho" value="#{cabecalhoBean.cabecalho.conteudo}" escape="false"/>
										</p:column>
										<p:column>
											<p:commandButton icon="ui-icon-pencil" id="btnEditarCab" update="@([id$=editarCabecalhoDialog])" 
												oncomplete="dialogEditarCabecalho.show();" action="#{cabecalhoBean.editarCabecalho}" value="Alterar"/>
										</p:column>
									</p:row>
								</p:panelGrid>
							</h:form>
		               	</p:layoutUnit>
               		</div>
				</p:layout>
			</p:layoutUnit>
	
			<!-- MENU -->
			<p:layoutUnit id="layoutMenu" position="west" size="204">
				<div align="center">
					<h:form id="formMenu">
						<p:menu style="width: 11.5em;">
							<p:submenu label="Menu">
								<p:menuitem value="Novo Aluno" icon="ui-icon-plusthick"	ajax="false" action="#{alunoBean.novoAluno}" />
								<p:menuitem value="Download Backup" icon="ui-icon-circle-arrow-s" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)">  
							    	<p:fileDownload value="#{alunoBean.arquivoBackup}" />  
								</p:menuitem>
							</p:submenu>	
						</p:menu>
					</h:form>
				</div>
			</p:layoutUnit>
	
			<p:layoutUnit id="layoutConteudo" position="center">
				
				<!-- PESQUISA -->
				<h:form id="formPesquisar">
					<p:panel header="Área de Pesquisa">
						<p:panelGrid columns="2">
							<h:outputLabel for="matricula-filter" value="Matrícula: " />
							<p:inputText id="matricula-filter" size="30" value="#{alunoBean.alunoFilter.matriculaFilter}" />
		
							<h:outputLabel for="nome-filter" value="Nome: " />
							<p:inputText id="nome-filter" size="80" value="#{alunoBean.alunoFilter.nomeFilter}" />
							
							<h:inputHidden />
							<p:commandButton value="Buscar" icon="ui-icon-search" action="#{alunoBean.procurarAluno}" update="@([id$=dataTableBusca])" />
						</p:panelGrid>
					</p:panel>
				</h:form>
		
				<!-- RESULTADO -->
				<h:form id="formResultado">
					<p:panel header="Resultado">
						<p:dataTable id="dataTableBusca" paginator="true" rows="5" var="aluno" value="#{alunoBean.resultadoDaBusca}"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="5,10,15">
		
							<p:column headerText="Matricula" width="20%">
								<h:outputText value="#{aluno.matricula}" />
							</p:column>
		
							<p:column headerText="Nome">
								<h:outputText value="#{aluno.nome}" />
							</p:column>
		
							<p:column headerText="Editar" width="10%">
								<div align="center">
									<p:commandButton icon="ui-icon-pencil" action="#{alunoBean.editarAluno}" ajax="false">
										<f:param name="aluno" value="#{aluno}" />
									</p:commandButton>
								</div>
							</p:column>
		
							<p:column headerText="Excluir" width="10%">
								<div align="center">
									<p:commandButton icon="ui-icon-trash" action="#{alunoBean.deletarAluno}" ajax="false">
										<f:param name="aluno" value="#{aluno}" />
									</p:commandButton>
								</div>
							</p:column>
		
							<p:column headerText="Imprimir" width="10%">
								<div align="center">
									<p:commandButton icon="ui-icon-print" action="#{alunoBean.dialogImpressao}" oncomplete="dialogImprimirAluno.show();">
										<f:param name="aluno" value="#{aluno}" />
									</p:commandButton>
								</div>
							</p:column>
							
						</p:dataTable>
					</p:panel>
				</h:form>
			</p:layoutUnit>
		
			<!--  DIALOG EDITAR CABEÇALHO -->
			<p:dialog widgetVar="dialogEditarCabecalho" modal="true" header="Editar Cabeçalho"
				width="530" showEffect="fade" hideEffect="fade" resizable="false" id="editarCabecalhoDialog">
				<h:form id="formEditarCabecalho">
					<p:editor widgetVar="editor" value="#{cabecalhoBean.conteudoCabecalho}" width="500"
						controls="bold italic underline font size color alignleft center alignright justify undo redo cut copy paste"/>
			
					<p:separator />
					<p:commandButton value="Cancelar" icon="ui-icon-close" onclick="dialogEditarCabecalho.hide()" type="button" />
					<p:commandButton value="Salvar" icon="ui-icon-disk" action="#{cabecalhoBean.salvarCabecalho}" 
								update="@([id$=textCabecalho])" oncomplete="dialogEditarCabecalho.hide()" />
				</h:form>
			</p:dialog>
			
			<!-- DIALOG IMPRIMIR ALUNO -->
			<p:dialog widgetVar="dialogImprimirAluno" modal="true" header="Imprimir Aluno"
				width="570" showEffect="fade" hideEffect="fade" resizable="false" id="imprimirAlunoDialog">
				<h:form id="formImprimir">
					<h:panelGrid border="0" style="margin-bottom:10px" cellpadding="5" columns="2">
						<h:outputLabel value="Adicionar cabeçalho à impressão?" />
						<p:selectBooleanButton value="#{alunoBean.adicionarCabecalho}" onLabel="Sim" offLabel="Não" />
						<h:outputLabel value="Deseja imprimir o aluno(a) " />
						<h:outputLabel value="#{alunoBean.aluno.nome} ? " styleClass="textoNegrito" />
					</h:panelGrid>
			
					<p:separator />
					<p:commandButton value="Cancelar" icon="ui-icon-close" onclick="dialogImprimirAluno.hide()" type="button" />
					<p:commandButton value="Imprimir" icon="ui-icon-print">
					</p:commandButton>
				</h:form>
			</p:dialog>
				
		</ui:define>
	</ui:composition>
</html>